%include "boot.inc"
section  .text
bits     16
extern   setup_start
global   _start

_start:
	mov ax, cs
	mov ds, ax
	mov es, ax
	mov ss, ax
	mov fs, ax
	mov sp, 0x7c00

	mov bp, _msg_hello
	mov ax, 0x1301
	mov bx, 0x0007
	mov cx, _msg_hello_len
	mov dx, 0
	int 0x10

_load:
	;   读 0x50 个扇区
	mov ax, 0x0250
	mov bx, setup_start
	;   从第 2 个扇区开始读; chs 扇区从 1 开始编号.
	mov cx, 0x0002
	mov dx, 0x0080
	int 0x13
	jc  _load

_ok_load:
	mov bp, _msg_load_ok
	mov ax, 0x1301
	mov bx, 0x000c
	mov cx, _msg_load_ok_len
	mov dx, 0x0100
	int 0x10

	jmp setup_start

_msg_hello:
	db "Hello, world!", 0

_msg_hello_end:
	_msg_hello_len equ _msg_hello_end - _msg_hello

_msg_load_ok:
	db "Load setup ok!", 0

_msg_load_ok_end:
	_msg_load_ok_len equ _msg_load_ok_end - _msg_load_ok

	times 510 - ($-$$) db 0
	db    0x55, 0xaa
